<template>

    <div>
        <Button type="primary" @click="checkcenter">发送</Button>
    </div>
</template>

<script>
    export default {
        name: "index",
        created(){
              // 初始化
              this.socket.initWebSocket('ws/127.0.0.1:8081',data=>{
                  console.log(data)
              })
            //页面销毁时关闭长连接
            window.addEventListener("beforeunload ",()=>{
                this.socket.websocketclose();
            })
        },
        destroyed:function(){
            //页面销毁时关闭长连接
            this.socket.websocketclose();
        },
        data() {
            return {}
        },
        methods: {
            checkcenter(){
                this.socket.sendSock(this.sendData)
            },
            sendData(){
                this.$axios({
                    method: 'get',
                    url: '/socket/checkcenter/socket/push/1',
                    params: {
                        message:'text'
                    },
                }).then(data => {
                    if (data.data.status === 'success') {
                    }
                })
            },
        }
    }
</script>

<style scoped>

</style>